package com.kaifamiao.mapper;


import com.kaifamiao.model.OrderModel;
import com.kaifamiao.model.SelectSeatModel;
import com.kaifamiao.provider.OrderProvider;
import com.kaifamiao.provider.SeatProvider;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface OrderModelMapper {

    //添加用户信息
    @Insert("<script>" +
            "INSERT INTO `order`(`fno`, `rno`, `sno`) VALUES (#{fno}, #{rno}, #{sno})"
            + "</script>")
    int insertOrder(@Param("fno")int fno, @Param("rno")String rno,@Param("sno") int sno);

    //查询用户的订座信息
    @Select("select * from `order` where id=#{id}")
    OrderModel selectById(Integer id);

    //查询用户的id
    @Select("select id from `order` where fno=#{fno} AND rno=#{rno} and sno=#{sno}")
    int selectOId(@Param("fno")int fno, @Param("rno")String rno,@Param("sno") int sno);

    //查询一个教室里所有被选的座位
    @SelectProvider(value = OrderProvider.class,method = "allSelectedSeats")
    List<OrderModel> allSelectedSeats(@Param("fno")int fno, @Param("rno")String rno);

    //删除 order表对应的订座记录
    @Update("DELETE FROM `order` WHERE `id` = #{id}")
    int deleteOrder(Integer id);




}
